<template>
	<view class="login">
		<view class="content">
			<image src="@/static/image/banner.jpeg" class="image" mode=""></image>
			<button type="default" class="button" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
				微信手机号登录
			</button>
			<view class="back-home" @click="backHome()">返回首页</view>
		</view>
	</view>
</template>

<script>
	import {
		getPhone
	} from '@/api/weixin.js'
	export default {
		name: "login",
		data() {
			return {
				mobile: "", //手机号
			}
		},
		onLoad(e) {

		},
		onShow() {

		},
		methods: {
			async getPhoneNumber(e) {
				let that = this;
				console.log(e)
				if (e.detail.errMsg == "getPhoneNumber:ok") {
					let params = {
						code: e.detail.code
					}
					const resPhone = await getPhone(params)
					console.log("resPhone: ", resPhone);
					if (resPhone.code == 0) {
						uni.navigateBack({
							delta: 1
						})
					}
				}
			},

			backHome() {
				uni.reLaunch({
					url: "/pages/home/index"
				})
			},

		}
	}
</script>

<style scoped lang="less">
	.login {
		width: 100%;
		height: 100%;
		display: flex;
		align-items: center;
		justify-content: center;

		.content {
			width: 300px;
			height: 300px;

			.image {
				width: 300px;
				height: 100px;
				margin-bottom: 20px;
			}

			.button {
				width: 90%;
				height: 96rpx;
				line-height: 96rpx;
				text-align: center;
				color: #fff;
				background: #02c161;
				border-radius: 80rpx;
				margin: 210rpx auto 0;
				font-size: 36rpx;
			}

			button:after {
				border: none !important;
			}

			.back-home {
				text-align: center;
				margin-top: 30rpx;
				color: #9aa4bf;
				font-weight: bolder;
				font-size: 30rpx;
			}
		}

	}
</style>
